import { GenTable } from '~/src/views/gen-code';
import { GenCodePreviewDto } from '~/src/views/gen-code/module/codePreview';
import { request } from '@/service/request';
import { GenTableInitDto } from '@/views/gen-code/module/sqlGen';


const moduleName = "/gen/table/"

export function featchGenTablePage(searchData:Common.SearchData<GenTable>){
	return request.post<GenTable[]>(moduleName+"list",searchData)
}
export function featchGenTable(id:Common.IdType){
	return request.get<GenTable>(moduleName+id)
}
export function featchAddGenTable(data:GenTable){
	return request.post(moduleName,data)
}
export function featchUpadteGenTable(data:GenTable){
	return request.put(moduleName,data)
}
export function featchAddGenTableByInitDto(data:GenTableInitDto){
	return request.post<Common.IdType>(moduleName+"initDto",data)
}

export function fetchDoGenCode(id:Common.IdType){
	return request.get<any>(moduleName+"doGen/"+id,{responseType:'blob'});
}

export function fetchPrviewCode(id:Common.IdType){
	return request.get<GenCodePreviewDto[]>(moduleName+"preview/"+id);
}

export function fetchDelGenCode(ids:Common.IdType[]){
    return request.delete(`${moduleName}/${ids}`,{});
}
